# 作者：小七
# 2024年12月27日

def use_dict_base():
    xiaoming_dict = {"name": "小明"}
    print(id(xiaoming_dict))

    print(xiaoming_dict["name"])

    xiaoming_dict["age"] = 18

    print(xiaoming_dict)

    xiaoming_dict["name"] = "小小明"

    print(xiaoming_dict)
    print(id(xiaoming_dict))

    xiaoming_dict.pop("name")
    print(xiaoming_dict)
    del xiaoming_dict["age"]
    print(xiaoming_dict)

    print(len(xiaoming_dict))

    temp_dict = {"height": 1.75, "age": 20}

    xiaoming_dict.update(temp_dict)
    print(xiaoming_dict)


def use_dict_iter():
    xiaoming_dict = {"name": "小明",
                     "qq": "123456",
                     "phone": "10086"}

    for k, v in xiaoming_dict.items():
        print(k, v)
    print('*' * 50)
    for kv in xiaoming_dict.items():
        print(kv)
    for j in xiaoming_dict:
        print(j, xiaoming_dict[j])
    for k in xiaoming_dict.keys():
        print(k)
    for v in xiaoming_dict.values():
        print(v)


def use_list_dict():
    card_list = [
        {"name": "张三",
         "qq": "12345",
         "phone": "110"},
        {"name": "李四",
         "qq": "54321",
         "phone": "10086"}
    ]
    for card_info in card_list:
        print(card_info)


def use_unpack_package():
    k, v, w = (1, 2, 3)
    print(k, v, w)


if __name__ == '__main__':
    use_dict_base()
    use_dict_iter()
    use_list_dict()
    use_unpack_package()
